﻿@model Ninesky.Models.Module
@{
    ViewData["Title"] = Model.Name;
}

<ol class="breadcrumb">
    <li><span class="fa fa-home"></span>  <a asp-controller="Home" asp-action="Index">首页</a></li>
    <li><a asp-controller="System" asp-action="Index">系统配置</a></li>
    <li><a asp-controller="Module" asp-action="Index">模块管理</a></li>
    <li class="active">@Model.Name</li>
</ol>


@section aside{

    @Html.Partial("SystemAside")
}
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
    <li role="presentation" class="active"><a href="#base" role="tab" data-toggle="tab">基本信息</a></li>
    <li role="presentation"><a href="#order" role="tab" data-toggle="tab">排序方式</a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
    <div role="tabpanel" class="tab-pane active" id="base">
        <input type="hidden" asp-for="ModuleId" />
        <dl class="dl-horizontal">
            <dt>
                <label asp-for="Name"></label>
            </dt>
            <dd>
                @Html.DisplayFor(model => model.Name)
            </dd>
            <dt>
                <label asp-for="Controller"></label>
            </dt>
            <dd>
                @Html.DisplayFor(model => model.Controller)
            </dd>
            <dt>
                <label asp-for="Description"></label>
            </dt>
            <dd>
                @Html.DisplayFor(model => model.Description)
            </dd>
            <dt>
                <label asp-for="Enabled"></label>
            </dt>
            <dd>
                <input type="checkbox" asp-for="Enabled" />
            </dd>
        </dl>
    </div>
    <div role="tabpanel" class="tab-pane" id="order"><table id="moduleordertable"></table></div>
</div>
@section Scripts {
    @{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
    <script type="text/javascript">
        $(document).ready(function () {
            $('#moduleordertable').bootstrapTable({
                url: '@Url.Action("OrderList",new{
            id=Model.ModuleId})',
                columns: [{
                    field: 'moduleOrderId',
                    title: '序号'
                }, {
                    field: 'name',
                    title: '名称',
                }, {
                    field: 'order',
                    title: '值'
                }]
            });
            $('#Enabled').click(function () {
                $.post('@Url.Action("Enable", "Module")', { id: $('#ModuleId').val(), enabled: $('#Enabled').prop('checked') }, function (response) { 
                    if(response.succeed)
                    {
                        BootstrapDialog.alert({
                            title:'消息',
                            message: response.message,
                            buttonLabel: '确定'
                        });

                    }
                }, 'json');
            });
        });
    </script>
}